
$(function() {	
	var _vv_option = {
		rules: {
			code: {
				remote: "contact.php?do=Customer.ajax_exist",
				required: true
			},
			name: "required",
			fullname: "required"
		},
		messages: {
			code: {
				remote: jQuery.format("{0} 已经存在")
			}
		},
		errorPlacement: function(label, element) {
			label.insertAfter(element);
		},
		success: function(label) {
			label.html("&nbsp;").addClass("checked");
		}
	};	
	
	validator = $("#form_add").validate(_vv_option);	
	
	$('#continent').selectChain({
		target: $('#country'),
		key: "code",
		value: "name",
		url: 'info.php?do=Country.ajax_continent',
		data: { ajax: true }
	}).trigger('change');
	
	$('textarea').css("width", 400);
	$('#code').css("width", 120);
	$('#name').css("width", 120);
	
	$("#code_t").click(function() {
		_code_t($(this));
	});
	
	_code_t($("#code_t"));
});

function _code_t(c) {
	var s = $("#code");
	if (c.attr("checked")) {
		c.val("1");
		s.attr("disabled", true);
	} else {
		c.val("2");
		s.attr("disabled", false);
	}
}